package com.caigou.modules.vote.adpter

import android.widget.ProgressBar
import com.caigou.modules.vote.R
import com.caigou.modules.vote.bean.VoteItemBean
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import kotlin.math.roundToInt

/**
 * @author #Suyghur.
 * Created on 2021/12/30
 */
class VoteItemAdapter(dataset: MutableList<VoteItemBean>) : BaseQuickAdapter<VoteItemBean, BaseViewHolder>(R.layout.item_vote_list, dataset) {

    override fun convert(holder: BaseViewHolder, item: VoteItemBean) {
        holder.setText(R.id.item_vote_tv_type, item.animalName)
        holder.getView<ProgressBar>(R.id.item_vote_process_bar).progress = (item.percent * 100).roundToInt()
        holder.setText(R.id.item_vote_tv_value, "${item.num}票 （${item.percent}%）")
    }
}